package org.sao.security.core.validate.code;

import org.sao.security.core.properties.SecurityProperties;
import org.sao.security.core.validate.code.image.ImageCodeGenerator;
import org.sao.security.core.validate.code.sms.DefaultSmsCodeSender;
import org.sao.security.core.validate.code.sms.SmsCodeSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ValidateCodeBeanConfig {
	
	
	@Autowired
	SecurityProperties securityProperties;
	
	@Bean
	@ConditionalOnMissingBean(name = "imageCodeGenerator")
	public ValidateCodeGenerator imageCodeGenerator(){
		ImageCodeGenerator CodeGenerator =new ImageCodeGenerator();
		CodeGenerator.setSecurityProperties(securityProperties);
		return CodeGenerator;
	}
	
	
	@Bean
	@ConditionalOnMissingBean(SmsCodeSender.class)
	public SmsCodeSender smsCodeSender(){
	return new DefaultSmsCodeSender();
	}
	
}
